<!DOCTYPE html>
<html>
<head>
    <title>用户管理</title>
    <#include "/header.html">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <#if shiro.hasPermission("cs:admin:save")>
        <button class="layui-btn layui-btn-normal" lay-event="add"><i class="layui-icon layui-icon-add-circle"></i> 添加 </button>
        </#if>
    </div>
</script>

<script type="text/html" id="currentTableStatusTpl">
    {{# if(d.status == 1){ }}
    <span class="layui-badge layui-bg-green">启用</span>
    {{# } else { }}
    <span class="layui-badge layui-bg-grey">禁用</span>
    {{# } }}
</script>

<script type="text/html" id="currentTableBar">
    <#if shiro.hasPermission("app:user:save")>
    <a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>修改</a>
    </#if>
</script>

<script type="text/javascript">
    var formDataId = 0;
    layui.use(['form', 'table', 'laytpl'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: serverUrl('cs/admin/list'),
            toolbar: '#toolbarDemo',
            // defaultToolbar: ['filter'],
            cols: [[
                {type: "numbers", width: 80},
                {field: 'showName', title: '昵称', minWidth: 150},
                {field: 'username', title: '登录名', minWidth: 150},
                {field: 'createTime', title: '创建时间', minWidth: 130},
                {field: 'status', title: '状态', width: 80, templet: '#currentTableStatusTpl'},
                {title: '操作', width: 150, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [15, 30, 50],
            limit: 15,
            page: true
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                formDataId = 0;
                openFormView('cs/admin/form.html', '添加客服');

            }
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                formDataId = data.id;
                openFormView('cs/admin/form.html', '修改客服');
            }
        });

        // 监听搜索操作
        initSearchForm('searchForm', 'currentTableId')

    });
</script>

</body>
</html>